(function(){
	'use strict';
	angular.module('services.workOrderData.problemMgmt')
	.factory('problemStatisticFactory',problemStatisticFactory);
	function problemStatisticFactory(Restangular,workOrderDataService){
		return {
			query: query,
			getName: getName,
			fmtOption: fmtOption

		};
		function query(params,callback){
			Restangular.all('sas/workOrderData/problemMgmt/query').post(params).then(callback);
		}
		function getName(code){
			var name = '';
			switch(code){
				case '15601' :
					name = '问题单数量';
					break;
				case 'h4002' :
					name = '已关闭问题单数量';
					break;
				case 'h4003' :
					name = '已关闭问题单所占比率';
					break;
				case 'h4004' :
				  name = '规定时间内解决问题数量';
					break;
				case 'h4005' :
					name = '规定时间内解决问题所占比率';
					break;
				case 'h4006' :
					name = '问题单平均解决时间';
					break;
			}
			return name;
		}
		function fmtOption(code,option){
			if(code === '15601' || code === 'h4002' || code === 'h4004'){
				option.tooltip.formatter = workOrderDataService.getFormatterFn('个');
				option.yAxis[0] = workOrderDataService.formatterYAxis('单位:(个)','');
			}else if(code === 'h4006'){
				option.tooltip.formatter = workOrderDataService.getFormatterFn('小时');
				option.yAxis[0] = workOrderDataService.formatterYAxis('单位:(小时)','');
			}else {
				option.tooltip.formatter = workOrderDataService.getFormatterFn('%');
				option.yAxis[0] = workOrderDataService.formatterYAxis('','{value}%');
			}
		}
	}
})();